﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;

public partial class Admin_Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string strType = txtType.Text.ToString();
        string strPropetyAddress = txtPropetyAddress.Text;
        string strCity = txtCity.Text;
        string strState = txtState.Text;
        string strZip = txtZip.Text;

        int Bedrooms = Convert.ToInt32(ddlBedrooms.SelectedValue);
        int Bathrooms = Convert.ToInt32(ddlBathrooms.SelectedValue);

        string strPrice = txtPrice.Text;
        string strSquarefeet = txtSquarefeet.Text;
        string strStatus = txtStatus.Text;
        string strRealEstateAgent = txtRealEstateAgent.Text;
        string strRealEstateCompany = txtRealEstateCompany.Text;
        string FileName = "";

        if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
        {
            string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
            if ((fileExt.ToUpper() == ".JPG") | (fileExt.ToUpper() == ".GIF") | (fileExt.ToUpper() == ".PNG"))
            {
                FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                string FilePath = Server.MapPath("~/HouseImg");

                FileUpload1.SaveAs(FilePath + "/" + FileName);
            }
        }

        ObjectDataSource1.InsertParameters["PropetyAddress"].DefaultValue = strPropetyAddress;
        ObjectDataSource1.InsertParameters["City"].DefaultValue = strCity;
        ObjectDataSource1.InsertParameters["State"].DefaultValue = strState;
        ObjectDataSource1.InsertParameters["Zip"].DefaultValue = strZip;
        ObjectDataSource1.InsertParameters["Price"].DefaultValue = strPrice;
        ObjectDataSource1.InsertParameters["Type"].DefaultValue = strType;
        ObjectDataSource1.InsertParameters["Squarefeet"].DefaultValue = strSquarefeet;
        ObjectDataSource1.InsertParameters["Status"].DefaultValue = strStatus;
        ObjectDataSource1.InsertParameters["RealEstateAgent"].DefaultValue = strRealEstateAgent;
        ObjectDataSource1.InsertParameters["RealEstateCompany"].DefaultValue = strRealEstateCompany;
        ObjectDataSource1.InsertParameters["Bedrooms"].DefaultValue = ddlBedrooms.SelectedValue;
        ObjectDataSource1.InsertParameters["Bathrooms"].DefaultValue = ddlBathrooms.SelectedValue;
        ObjectDataSource1.InsertParameters["ImageUrl"].DefaultValue = FileName;
        ObjectDataSource1.Insert();


    }
}